package com.itheima.pojo;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @Author weizhongli
 * @Date 2020/5/6
 * @Version v1.0
 * @Description
 *
 **/
/*
* @Document : 声明一个文档 定义文档所在的索引库名称，定义文档所在类型名称，定义分片和副本
* */
@Document(indexName = "heima1",type = "goods",shards = 5,replicas = 1)
public class Goods {

    /*
    * 定义实体类 必须唯一主键
    * 元数据， _id,唯一标识
    *   将类型中的—_id唯一主键与当前字段进行绑定
    * */
    @Id
    private Long id;//商品的唯一标识
    /**
     * type: 字段数据类型
     * analyzer: 分词器类型
     * index: 是否索引(默认值：true)
     * store: 是否存储(默认值：false)
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String title;//标题
    @Field(type = FieldType.Keyword)
    private String category;//分类
    @Field(type = FieldType.Keyword)
    private String brand;//品牌
    @Field(type = FieldType.Double)
    private Double price;//价格
    @Field(type = FieldType.Keyword,index = false)
    private String images;//图片地址

    public Goods() {
    }

    public Goods(Long id, String title, String category, String brand, Double price, String images) {
        this.id = id;
        this.title = title;
        this.category = category;
        this.brand = brand;
        this.price = price;
        this.images = images;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getImages() {
        return images;
    }

    public void setImages(String images) {
        this.images = images;
    }

    @Override
    public String toString() {
        return "Goods{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", category='" + category + '\'' +
                ", brand='" + brand + '\'' +
                ", price=" + price +
                ", images='" + images + '\'' +
                '}';
    }
}
